#pragma GCC optimize(2,3,"Ofast","inline")
#include<bits/stdc++.h>
#define ll long long
#define eb emplace_back
#define ep emplace
#define pii pair<int,int>
#define piii pair<int,pii>
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define mems(arr,x) memset(arr,x,sizeof(arr))
#define memc(arr1,arr2) memcpy(arr1,arr2,sizeof(arr2))
using namespace std;
const int maxn=1e6+10,inf=1e9;
const int n=1e6;
bool mem1;
int q;
multiset<pii> sl,sr;
priority_queue<int> sL;
priority_queue<int,vector<int>,greater<int>> sR;
int sls[maxn],srs[maxn];
piii in[maxn];
inline void getmn(int &x,int y){(x>y)&&(x=y);}
namespace FastIO{
    const int SIZ=1000000;static char buf[SIZ+10],*p1=buf,*p2=buf,obuf[SIZ+10],*p3=obuf,cc[40];
    inline void flush(){fwrite(obuf,p3-obuf,1,stdout);}
    inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZ,stdin),p1==p2)?EOF:*p1++;}
    inline void putc(char x){(p3-obuf<SIZ)?(*p3++=x):(fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=x);}
    inline int read(){int x=0,f=1;char c=getc();while(c<48||c>57){if(c=='-')f=-1;c=getc();}while(c>=48&&c<=57)x=(x<<3)+(x<<1)+(c^48),c=getc();x*=f;return x;}
    inline char readc(){char c=getc();while(c^65&&c^82)c=getc();return c;}
    inline ll readll(){ll x=0,f=1;char c=getc();while(c<48||c>57){if(c=='-')f=-1;c=getc();}while(c>=48&&c<=57)x=(x<<3)+(x<<1)+(c^48),c=getc();x*=f;return x;}
    inline void print(auto x){if(!x)return putc(48),void();int len=0;if(x<0)x=-x,putc(45);while(x)cc[len++]=x%10+48,x/=10;while(len--)putc(cc[len]);}
}
using FastIO::read;using FastIO::readll;using FastIO::print;using FastIO::getc;using FastIO::putc;using FastIO::flush;using FastIO::readc;
namespace SegmentTree{
    #define ls (p<<1)
    #define rs (p<<1|1)
    #define lson ls,l,mid
    #define rson rs,mid+1,r
    #define all 1,1,n
    #define setmid int mid=(l+r)>>1
    #define setpos int p,int l,int r
    int tr[maxn<<2],mxl[maxn<<2];
    bool havson[maxn<<2];
    priority_queue<int,vector<int>,greater<int>> tag[maxn<<2];
    priority_queue<int> a[maxn];
    unordered_multiset<int> tags[maxn],as[maxn];
    inline void slv(int p){while(!tag[p].empty()){int x=tag[p].top();auto it=tags[x].find(p);if(it!=tags[x].end()){tags[x].erase(it);tag[p].pop();}else break;}}
    inline void slva(int p){while(!a[p].empty()){int x=a[p].top();auto it=as[p].find(x);if(it!=as[p].end()){as[p].erase(it);a[p].pop();}else break;}}
    inline void pu(int p){if(havson[p]) mxl[p]=max(mxl[ls],mxl[rs]);slv(p);tr[p]=tag[p].empty()?inf:tag[p].top()-mxl[p]+1;if(havson[p]){getmn(tr[p],tr[ls]);getmn(tr[p],tr[rs]);}}
    inline void pt(int p,int s,bool o){if(o)tag[p].ep(s);else tags[s].ep(p);pu(p);}
    void upd(setpos,int pl,int pr,int s,bool o){if(l>=pl&&r<=pr)return pt(p,s,o),void();setmid;if(pl<=mid)upd(lson,pl,pr,s,o);if(pr>mid)upd(rson,pl,pr,s,o);pu(p);}
    inline void mdf(int x,int s,bool o){
        int l=1,r=n,p=1;
        while(l<r){setmid;(x<=mid)?(p=ls,r=mid):(p=rs,l=mid+1);}
        if(o)   a[x].ep(s);
        else    as[x].ep(s);
        slv(p);slva(x); 
        mxl[p]=a[x].empty()?-inf:a[x].top();
        tr[p]=tag[p].empty()?inf:tag[p].top()-mxl[p]+1;
        while(p)pu(p>>=1);
    }
    inline void print(setpos){
        if(l==r){
            if(mxl[p]>0||tr[p]<=n)  printf("%d %d %d : %d %d\n",p,l,r,mxl[p],tr[p]);
            return;
        }
        setmid;print(lson);print(rson);
        if(mxl[p]>0||tr[p]<=n)    printf("%d %d %d : %d %d\n",p,l,r,mxl[p],tr[p]);
    }
    void build(setpos){tr[p]=inf;mxl[p]=-inf;havson[p]=(l^r);if(l==r)return;setmid;build(lson);build(rson);}
}
using namespace SegmentTree;
bool len0=false;
inline void ins(int l,int r){
    sL.ep(l);sR.ep(r);
    if(!len0){sl.ep(l,r);sr.ep(r,l);}
    mdf(r,l,true);
    if(l>1) upd(all,1,l-1,r,true);
}
inline void era(int l,int r){
    sls[l]++;srs[r]++;
    if(!len0){sl.erase(sl.find(pii(l,r)));sr.erase(sr.find(pii(r,l)));}
    mdf(r,l,false);
    if(l>1) upd(all,1,l-1,r,false);
}
bool mem2;
int main(){
    freopen("stone.in","r",stdin);freopen("stone.out","w",stdout);
    debug("%.2fMB\n",abs(&mem1-&mem2)/1024./1024);
    build(all);
    q=read();
    int lst=1;
    for(int i=1;i<=q;i++){
        char c=readc();int l=read(),r=read()-1;
        in[i]=piii(c=='A',pii(l,r));
        if(c=='A')   ins(l,r);
        else    era(l,r);
        while(sls[sL.top()])    --sls[sL.top()],sL.pop();
        while(srs[sR.top()])    --srs[sR.top()],sR.pop();
        if(sL.top()<=sR.top()){
            if(len0){
                for(int j=lst;j<=i;j++)
                    if(in[j].fi) sl.ep(in[j].se),sr.ep(in[j].se.se,in[j].se.fi);
                    else    sl.erase(sl.find(in[j].se)),sr.erase(sr.find(pii(in[j].se.se,in[j].se.fi)));
                len0=false;
            }
            int L=prev(sr.lower_bound(pii(sr.begin()->fi+1,0)))->se,R=sl.lower_bound(pii(prev(sl.end())->fi,0))->se;
            print(R-L+1);
        }
        else if(len0)   print(tr[1]);
        else{print(tr[1]);len0=true;lst=i+1;}
        putc('\n');
    }
    flush();
}